package com.klhappy.houyuan.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.klhappy.houyuan.R;

public class SearchDialogAdapter extends BaseAdapter{
	
	private Context mContext;
	private List<String> list;
	
	public SearchDialogAdapter(Context mContext, List<String> list) {
		super();
		this.mContext = mContext;
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup group) {
		// TODO Auto-generated method stub
		ViewHolder holder;
		if(view == null){
			view = LayoutInflater.from(mContext).inflate(R.layout.activity_dialog_search, null);
			holder = new ViewHolder();
			holder.textView=(TextView) view.findViewById(R.id.dialog_text);
			
			view.setTag(holder);
		} else {
			holder = (ViewHolder)view.getTag();
		}
		
		holder.textView.setText(list.get(position).toString());
		return view;
	}

	class ViewHolder{
		TextView textView;
	}
}
